#!/bin/bash

owner=$1
o_sid="qmjk"
set -ex;

function export_file()
{
    name=$1
    PATH=$PATH:$HOME/.local/bin:$HOME/bin

    export ORACLE_BASE=/u01/app/oracle
    export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/$o_sid
    export ORACLE_SID=$o_sid
    export LD_LIBRAY_PATH=$ORACLE_HOME/lib
    export NLS_LANG="SIMPLIFIED CHINESE_CHINA.UTF8"
    export PATH=$PATH:$ORACLE_HOME/bin

    n_month=`date +%m`
    n_day=`date +%d`
    n_year=`date +%Y`

    n_bak_file="/home/oracle/dat_bak/"$name$n_year$n_month$n_day"db.dmp"
    echo $n_bak_file

    exp system/qmjkAdmin@blood file=$n_bak_file owner=$name
}


if [ $owner != "hssa" -a $owner != "mangkhut" ];then
    echo "$owner is illegal."
    export_file "hssa"
    export_file "mangkhut"
else
    export_file $owner
fi


